<template>
	<view>

	</view>
</template>

<script>
	import cropper from "@/components/lxiaoxiao-cropper/lxiaoxiao-cropper.vue";
    import $baseUrl from "@/config/index.js"
	export default {
		components: {
			cropper
		},
		data() {
			return {
				imgurl: "/static/image/icon-down.png",
			}
		},
		onLoad(e) {
            this.imgurl =''
            console.log( $baseUrl );
			// this.imgurl = e.imgSrc
		},
        onShow() {
			this.$nextTick(function() {
                this.$refs.cropper.fSelect()
			})
		},
		methods: {
			//上传返回图片
			myUpload(rsp) {
				const self = this;
				self.imgurl = rsp.path; //更新头像方式一
				uni.uploadFile({
					url: $baseUrl.baseUrl + 'api/common/upload',
					filePath: rsp.tempFilePath,
					name: 'file',
                    header: {
                        'token': uni.getStorageSync('token'),
                    },
					success: function(res) {

						if (res.statusCode == 200) {
							uni.showToast({
								title: '上传成功',
								icon: 'none'
							});
                            let imgSrc = JSON.parse(res.data).data.fullurl
                            console.log(imgSrc)
                            uni.redirectTo({
                            	url:'/pageA/mine/personalData/personalData?imgSrc='+imgSrc
                            })
						} else {
							uni.showToast({
								title: '上传失败',
                                icon: 'none'
							})
						}
					}
				})
				// uni.redirectTo({
				// 	url:'/pageA/mine/personalData/personalData'
				// })
				// rsp.avatar.imgSrc = rsp.path; //更新头像方式二
			},
            fClose(){
                uni.navigateBack()
            }
		}
	}
</script>

<style>

</style>
